﻿using System;
using System.Collections.Generic;
using TSites.EmailEntity.Template;

namespace TSites.EmailEntity.Entities
{
	[Serializable]
	public class EmailTemplateMsg : EmailMsgBase
	{
		//public EmailTemplateMsg(IContent content)
		//    : base(content)
		//{ }

		public int ID { get; set; }
		public object[] EmailParams { get; set; }

		#region IContent Members

		public override void BuildSubjectBody()
		{
			Dictionary<string, EmailTemplate> dicEmailTemp;
			if (Common.EmailTempHash.TryGetValue(ID, out dicEmailTemp))
			{
				EmailTemplate emailTemp;
				if (dicEmailTemp.TryGetValue(Locale, out emailTemp))
				{
					Subject = emailTemp.Subject;
					Body = string.Format(emailTemp.Template, EmailParams);
				}
			}
		}

		#endregion
	}
}
